package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.system.domain.Emplyee;
import com.ruoyi.system.domain.Leave;
import com.ruoyi.system.mapper.EmplyeeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.SalaryMapper;
import com.ruoyi.system.domain.Salary;
import com.ruoyi.system.service.ISalaryService;

/**
 * salaryService业务层处理
 *
 * @author ruoyi
 * @date 2023-10-13
 */
@Service
public class SalaryServiceImpl implements ISalaryService
{
    @Autowired
    private SalaryMapper salaryMapper;

    @Autowired
    private EmplyeeMapper emplyeeMapper;

    /**
     * 查询salary
     *
     * @param id salary主键
     * @return salary
     */
    @Override
    public Salary selectSalaryById(Long id)
    {
        Salary salary = salaryMapper.selectSalaryById(id);
        Emplyee emplyee = emplyeeMapper.selectEmplyeeByEno(salary.getEno());
        salary.setName(emplyee.getName());
        salary.setEmplyee(emplyee);
        return salary;
    }

    /**
     * 查询salary列表
     *
     * @param salary salary
     * @return salary
     */
    @Override
    public List<Salary> selectSalaryList(Salary salary)
    {
        List<Salary> salaryList = salaryMapper.selectSalaryList(salary);
        for (Salary salar : salaryList) {
            salar.setEmplyee(emplyeeMapper.selectEmplyeeByEno(salar.getEno()));
        }
        return salaryList;
    }

    /**
     * 新增salary
     *
     * @param salary salary
     * @return 结果
     */
    @Override
    public int insertSalary(Salary salary)
    {
        return salaryMapper.insertSalary(salary);
    }

    /**
     * 修改salary
     *
     * @param salary salary
     * @return 结果
     */
    @Override
    public int updateSalary(Salary salary)
    {
        return salaryMapper.updateSalary(salary);
    }

    /**
     * 批量删除salary
     *
     * @param ids 需要删除的salary主键
     * @return 结果
     */
    @Override
    public int deleteSalaryByIds(Long[] ids)
    {
        return salaryMapper.deleteSalaryByIds(ids);
    }

    /**
     * 删除salary信息
     *
     * @param id salary主键
     * @return 结果
     */
    @Override
    public int deleteSalaryById(Long id)
    {
        return salaryMapper.deleteSalaryById(id);
    }
}
